<template>
	<view class="content" v-if="show">
		<!-- 导航 -->
		<view class="bwh-100 w-fixed-top w-row-justify-between-align w-bj-cont">
			<view class="wh-80 w-row-center" @click="routerBack()">
				<image class="wh-45" src="../../../static/gane/fh.png"></image>
			</view>
			<view class="w-250 h-100 w-row-center  w-wz-conts font-34b">房间选择</view>
			<view class="wh-80 w-row-center "></view>
		</view>
		<view class="bwh-120"></view>


		<view style="border: solid 1rpx #b5a072; margin-bottom: 20rpx;"
			class="w-720 h-280 w-bj-cont  w-bor-12 w-row-center w-relative" v-for="item in roomList">
			<image class="w-720 h-280" :src="item.room_imgurl"></image>
			<view class="w-720 h-280 w-absolute-left w-row-justify-between-align">
				<view class="w-350 h-230">
					<!-- <view class="w-row-align w-wz-conts m-left-20">
						<image class="wh-30" src="../../../static/gane/gz2.png"></image>
						<text class="font-26 m-left-6 m-bottom-4">房间规则</text>
					</view> -->
				</view>
				<view class="w-350 w-wz-white w-column-align">
					<view class="font-40b w-wz-conts">{{item.room_name}}</view>
					<view class="h-30"></view>

					<view class="w-150 h-50 w-row-center w-wz-conts w-bj-black w-bk-conts w-bor-50 font-26"
						@click="toRoomindex(item)">
						<text class="m-bottom-4">点击进入</text>
					</view>

					<view class="h-30"></view>
					<view class="w-row-align">
						<text class="font-26 w-wz-conts">进入要求：￥{{item.room_money}}</text>
					</view>
				</view>
			</view>
		</view>


	</view>
</template>

<script>
	import $H from '@/pages/common/request.js'
	export default {
		data() {
			return {
				roomList: [],
				UserInfo: {},
				money: null,
				show:false
			}
		},

		onLoad() {

			this.UserInfo = uni.getStorageSync('UserInfo');
			if (this.UserInfo.uid && this.UserInfo.token) {
				this.getRoomList()
			} else {
				return uni.reLaunch({
					url: '/pages/index/index'
				});
			}

		},

		methods: {
			// 获取房间列表
			getRoomList() {
				$H.post('/app_aomen_room_list').then((res) => {
					
					if (res.code == 200) {
						this.roomList = res.data.room_list
						this.money = res.data.user_monye
						this.show = true
					} else {
						uni.clearStorageSync()
						uni.reLaunch({
							url: '/pages/index/index'
						});
						return uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
			},

			// 进入房间
			toRoomindex(item) {

				if (Number(this.money) < Number(item.room_money)) {
					return uni.showToast({
						title: `房间进入余额需${item.room_money}`,
						duration: 2000,
						icon: 'none'
					});
				}

				uni.navigateTo({
					url: `/pages/game/aomen/index?room_label=${item.room_label}`
				});
			},

			


		}
	}
</script>
<style>

</style>
